<template>
	<view class="d-flex flex-column j-sb px-3 pt-2 border-top">
		<view v-for="(item, index) in collectionList" :key="index">
			<news-item :item="item"></news-item>
		</view>
	</view>
</template>

<script>
	import newsItem from '@/components/module/news-item.vue';
	import api from '@/common/lib/request.js';
	export default {
		data() {
			return {
				collectionList:[],
				username: ""
			}
		},
		components:{
			newsItem
		},
		onLoad(option){
			this.username = option.username;
		},
		onShow(){
			this.initCollectList()
		},
		methods: {
			// 初始化收藏列表
			initCollectList() {
				const _this = this;
				api.request({
						url: '/user/collectionList',
						data: {
							username: _this.username
						}
					})
					.then(response => {
						console.log(response)
						_this.collectionList = response.map(item => {
							return {
								title: item.title,
								releaseDate: item.releaseDate.split(' ')[0],
								url: item.url,
								origin: item.origin,
								releaseDataDes: item.releaseDateDes,
								thumb: item.thumb,
								id: item.id
							}
						})
					})
					.catch(err => {
						console.log(err);
					});
			},
		}
	}
</script>

<style>

</style>
